<template>
  <div class="wrapper">
    <swiper class="swiper_container" :options="swiperOption" v-if="show">
      <swiper-slide v-for="item of swiperList" :key="item.id">
        <img class="swiperImg" :src="item.url" alt="" />
      </swiper-slide>
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>
<script>
export default {
  name: 'HomeSwiper',
  props: {
    swiperList: {
      type: [Array],
      required: true
    }
  },
  data () {
    return {
      swiperOption: {
        loop: true,
        pagination: {
          el: '.swiper-pagination'
        }
      }
    }
  },
  computed: {
    show () {
      return this.swiperList.length
    }
  }
}
</script>
<style lang="stylus" scoped>
.wrapper  {
  width: 100%;
  height: 0;
  padding-bottom: 50%;
  overflow: hidden;

  .swiperImg {
    width: 100%;
  }

  >>>.swiper-pagination-bullet-active {
    background: #fff;
  }
}
</style>
